<?xml version='1.0' encoding='ISO-8859-1' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:component xmlns="http://www.w3.org/1999/xhtml"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:ui="http://java.sun.com/jsf/facelets"
              xmlns:p="http://primefaces.org/ui">


    <h:form id="formList" styleClass="jsfcrud_list_form">
        <h3><h:outputText value="#{bundle.OrgaoUsinaTitleRelacionamento}" /></h3>        

        <h:panelGroup>

            <p:dataTable value="#{orgaoUsinaController.lista}" var="item"  paginator="true" rows="10"
                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                         rowsPerPageTemplate="5,10,15,20,30,50" rowKey="#{item.ousId}" paginatorPosition="both" emptyMessage="#{bundle.ListOrgaoUsinaEmpty}" selection="#{orgaoUsinaController.selectedOrgaoUsina}" selectionMode="single">

                <p:column styleClass="firstColumn" filterBy="#{item.ousId}" sortBy="#{item.ousId}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListOrgaoUsinaTitle_ousId}"/>
                    </f:facet>
                    <h:outputText value="#{item.ousId}"/>
                </p:column>

                <p:column filterBy="#{item.ousOrgId.orgNm}" sortBy="#{item.ousOrgId.orgNm}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListOrgaoUsinaTitle_ousOrgId}"/>
                    </f:facet>
                    <h:outputText value="#{item.ousOrgId.orgNm}"/>
                </p:column>

                <p:column filterBy="#{item.ousUsiId.usiNm}" sortBy="#{item.ousUsiId.usiNm}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListOrgaoUsinaTitle_ousUsiId}"/>
                    </f:facet>
                    <h:outputText value="#{item.ousUsiId.usiNm}"/>
                </p:column>


                <f:facet name="footer">                            
                    <p:commandButton id="createCommand" ajax="false" icon="ui-icon-document" action="#{orgaoUsinaController.prepareCreate}" value="#{bundle.ListOrgaoUsinaCreateLink}"/>
                    <p:commandButton id="viewCommand" value="#{bundle.MsgVisualizar}" icon="ui-icon-search"  update=":formList:displayView" oncomplete="orgaoUsinaDialogView.show()" />
                    <p:commandButton id="editCommand" ajax="false"  action="#{orgaoUsinaController.prepareEdit}" value="#{bundle.ViewOrgaoUsinaEditLink}" icon="ui-icon-pencil" />
                    <p:commandButton id="deleteCommand"  onclick="confirmationDestroy.show()" value="#{bundle.ViewOrgaoUsinaDestroyLink}" type="button" icon="ui-icon-trash" />
                </f:facet>
            </p:dataTable>
            <p:confirmDialog id="confirmDestroy" message="#{bundle.MsgConfirmDestroy_message}" header="#{bundle.MsgConfirmDestroy_header}" severity="alert" widgetVar="confirmationDestroy">
                <p:commandButton id="confirm" ajax="false" value="#{bundle.MsgDialog_confirmar}"  oncomplete="confirmationDestroy.hide();" actionListener="#{orgaoUsinaController.destroy}" />
                <p:commandButton id="decline"  value="#{bundle.MsgDialog_cancelar}" update="messages" onclick="confirmationDestroy.hide()" type="button"/>

            </p:confirmDialog>

            <p:dialog id="dialogView" header="#{bundle.OrgaoUsinaDialogView_header}" widgetVar="orgaoUsinaDialogView" resizable="false" width="500" >

                <h:panelGrid id="displayView" columns="2" cellpadding="4">                          

                    <h:outputText value="#{bundle.ViewOrgaoUsinaLabel_ousId}"/>
                    <h:outputText value="#{orgaoUsinaController.selected.ousId}" title="#{bundle.ViewOrgaoUsinaTitle_ousId}"/>
                    <h:outputText value="#{bundle.ViewOrgaoUsinaLabel_ousUsiId}"/>
                    <h:outputText value="#{orgaoUsinaController.selected.ousUsiId.usiNm}" title="#{bundle.ViewOrgaoUsinaTitle_ousUsiId}"/>
                    <h:outputText value="#{bundle.ViewOrgaoUsinaLabel_ousOrgId}"/>
                    <h:outputText value="#{orgaoUsinaController.selected.ousOrgId.orgNm}" title="#{bundle.ViewOrgaoUsinaTitle_ousOrgId}"/>                      
                </h:panelGrid>
            </p:dialog>

        </h:panelGroup>
    </h:form>
</ui:component>

